package enumdemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Text {
    public static void main(String[] args) {
        try {
            Class<?> c1 = Class.forName("enumdemo.TextEnum");
            Constructor<?>constructor=
                    c1.getDeclaredConstructor(String.class,int.class,int.class,String.class);
            constructor.setAccessible(true);
            TextEnum textEnum=
                    (TextEnum) constructor.newInstance(4,"RED");
            System.out.println(textEnum);//枚举用不了反射，保证单线程安全

        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }


    }
}
